package com.jye.rseven.user.serivce.impl;

import org.springframework.stereotype.Service;
import com.jye.rseven.domain.Address;
import com.jye.rseven.service.AddressService;
import com.jye.rseven.user.mapper.AddressMapper;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.List;


@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    AddressMapper addressMapper;


    @Override
    public int addAddress(Address address) {
        try {
            addressMapper.addAddress(address);
            return 1;
        }catch (Exception e){
            return 0;
        }
    }

    @Override
    public int updateAddress(Address address) {
        try {
            addressMapper.updateAddress(address);
            return 1;
        }catch (Exception e){
            return 0;
        }
    }

    @Override
    public List<Address> findAddressByUId(int uId) {
        List<Address> select = addressMapper.findAddressByUId(uId);
        return select;
    }

    @Override
    public int deleteAddressById(int id) {
        try {
            addressMapper.deleteAddressById(id);
            return 1;
        }catch (Exception e){
            return 0;
        }
    }
}
